{include file="public/header"}
<div class="bg_fixed_v10_1"></div>
<body class="">
<div class="sectionY sectionY_tttt">
    <a href="javascript:history.back();">
        <img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1">
    </a>
    <p class="p1">
        <span class="ppp_title">SCB转赠</span>
    </p>
</div>
<div class="kong1"></div>
<div class="ecx_section1">
    <div class="container">
        <p class="p2">提醒：</p>
        <p class="p1">SCB一旦转赠成功，不可退回。最低转增：{:config("setting.transpoint")}个。只能给自己团队的人转</p>
    </div>
</div>
<div class="ecx_section2">
    <div class="t1">
        <div class="t2">
            <div class="f1 clearfix">
                <span class="s1">可用共享豆：</span>
                <div class="k1">
                    <span class="s2">{$userinfo.integral}</span>
                </div>
            </div>
            <div class="f1 clearfix">
                <span class="s1">转赠数量：</span>
                <input type="number" name='nums' placeholder="" />
            </div>
            <div class="f1 clearfix" style="border-bottom: none">
                <span class="s1">对方账号：</span>
                <input type="text" name='account' placeholder="对方的手机号码" />
            </div>
        </div>
        <div class="sub">
            <input type="button" value="确认转赠" id="submit"/>
            <p class="p1">提示：请先通过实名认证再进行转赠</p>
        </div>
    </div>
</div>
</body>
<script>
    $(function(){
        $('#submit').click(function(){
            var num = $('input[name=nums]').val();
            var tel = $('input[name=account]').val();
            if(num=='' || num<{:config("setting.transpoint")}){
                layer.alert('请检查转增数量',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            var pattern = /^1\d{10}$/;
            if(!pattern.test(tel)){
                layer.alert('手机号格式错误，请检查！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
            }
            $.ajax({
                type: 'POST',
                url: "{:url('Set/transpoint')}",
                dataType: "html",
                data: "num="+num+"&tel="+tel,
                success:function(responsestr){
                    var str = isJSON(responsestr);
                    if(str==1){
                        var obj=JSON.parse(responsestr);
                        if(obj.s==10){
                            layer.msg('成功！',{shade:0.6,time:1000,end:function(){
                                    window.location.href=window.location.href;
                                    return false;
                                }});
                        }else{
                            layer.alert(obj.msg,{shade:0.2});return false;
                        }
                    }else{
                        layer.alert('系统正忙，请稍后再试！',{shade:0.2});
                    }
                },
                error:function(){
                    layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
                }
            });
        });
    })

    function isJSON(str) {
        if (typeof str == 'string') {
            try{
                var obj=JSON.parse(str);
                if(str.indexOf('{')>-1){
                    return 1;
                }else{
                    return 0;
                }
            }catch(e){
                return 0;
            }
        }
        return 0;
    }
</script>
</html>
